package router

import (
	"gin_demo_BubbleList/controller"
	"github.com/gin-gonic/gin"
)

func SetRouter() *gin.Engine {
	r := gin.Default()
	//设置静态资源文件
	r.Static("/static", "static")
	// 设置gin框架模版文件
	r.LoadHTMLGlob("templates/*")

	//设置路由
	r.GET("/", controller.IndexHandler)
	//设置路由组
	v1Group := r.Group("/v1")
	{
		//添加一个事项
		v1Group.POST("/todo", controller.Create)
		//查看所有事项
		v1Group.GET("/todo/", controller.GetTodoList)
		//修改一个事项
		v1Group.PUT("/todo/:id", controller.UpdateById)
		//删除一个事项
		v1Group.DELETE("/todo/:id", controller.DeleteById)
	}
	return r
}
